package com.ruoyi.web.controller.business;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.HurtRecoveryGuide;
import com.ruoyi.business.service.IHurtRecoveryGuideService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 康复指导Controller
 *
 * @author ruoyi
 * @date 2024-04-20
 */
@RestController
@RequestMapping("/business/recoveryGuide")
public class HurtRecoveryGuideController extends BaseController
{
    @Autowired
    private IHurtRecoveryGuideService hurtRecoveryGuideService;

    /**
     * 查询康复指导列表
     */
    @PreAuthorize("@ss.hasPermi('business:recoveryGuide:list')")
    @GetMapping("/list")
    public TableDataInfo list(HurtRecoveryGuide hurtRecoveryGuide)
    {
        startPage();
        List<HurtRecoveryGuide> list = hurtRecoveryGuideService.selectHurtRecoveryGuideList(hurtRecoveryGuide);
        return getDataTable(list);
    }

    /**
     * 导出康复指导列表
     */
    @PreAuthorize("@ss.hasPermi('business:recoveryGuide:export')")
    @Log(title = "康复指导", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HurtRecoveryGuide hurtRecoveryGuide)
    {
        List<HurtRecoveryGuide> list = hurtRecoveryGuideService.selectHurtRecoveryGuideList(hurtRecoveryGuide);
        ExcelUtil<HurtRecoveryGuide> util = new ExcelUtil<HurtRecoveryGuide>(HurtRecoveryGuide.class);
        util.exportExcel(response, list, "康复指导数据");
    }

    /**
     * 获取康复指导详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:recoveryGuide:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hurtRecoveryGuideService.selectHurtRecoveryGuideById(id));
    }

    /**
     * 新增康复指导
     */
    @PreAuthorize("@ss.hasPermi('business:recoveryGuide:add')")
    @Log(title = "康复指导", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HurtRecoveryGuide hurtRecoveryGuide)
    {
        return toAjax(hurtRecoveryGuideService.insertHurtRecoveryGuide(hurtRecoveryGuide));
    }

    /**
     * 修改康复指导
     */
    @PreAuthorize("@ss.hasPermi('business:recoveryGuide:edit')")
    @Log(title = "康复指导", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HurtRecoveryGuide hurtRecoveryGuide)
    {
        return toAjax(hurtRecoveryGuideService.updateHurtRecoveryGuide(hurtRecoveryGuide));
    }

    /**
     * 删除康复指导
     */
    @PreAuthorize("@ss.hasPermi('business:recoveryGuide:remove')")
    @Log(title = "康复指导", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hurtRecoveryGuideService.deleteHurtRecoveryGuideByIds(ids));
    }


    /**
     * 获取康复指导列表
     * @return
     */
    @GetMapping("/getRecoveryGuideList")
    public AjaxResult getRecoveryGuideList(){
        List<Map<String, Object>> list = hurtRecoveryGuideService.getRecoveryGuideList();
        return AjaxResult.success(list);
    }
}
